<template>
    <div style="width: 100%">
        <el-radio-group v-if="!isInstanceSearch" :style="selectStyle" :disabled="isDisable" v-model="properties.bindValue">
            <el-radio v-for="item in selectOptionList" :key="item[properties.optionValue]"
                      :value="item[properties.optionValue]">
                {{item[properties.optionLabel]}}
            </el-radio>
        </el-radio-group>

        <el-radio-group v-if="isInstanceSearch" :style="selectStyle" :disabled="isDisable" v-model="properties.searchValue">
            <el-radio v-for="item in selectOptionList" :key="item[properties.optionValue]"
                      :value="item[properties.optionValue]">
                {{item[properties.optionLabel]}}
            </el-radio>
        </el-radio-group>
    </div>
</template>

<script setup lang="ts" name="YwuFormRadio">
import {computed, defineProps, ref} from "vue";
import {doFromInfoValue} from "@/views/bpmn/form/formUtils.ts";

let props = defineProps(['isEdit', 'properties', 'isInstanceSearch', "isDisable", "formBuildList"]);

let isEdit = computed(() => {return props['isEdit']})
let properties = computed(() => {return props['properties']})
let isInstanceSearch = computed(() => {return props['isInstanceSearch']})
let isDisable = computed(() => {return props['isDisable']})
let formBuildList = computed(() => {return props['formBuildList']})

let selectOptionList = ref([])

let selectStyle = computed(() => {
    if (isEdit.value) {
        return "pointer-events: none;"
    } else {
        return "";
    }
})

function execFunc(resList) {
    selectOptionList.value = resList
}

init()
function init() {
    doFromInfoValue(properties.value, formBuildList.value, execFunc)
}
</script>

<style scoped lang="less">

</style>